﻿using System.Text;
using CompactMapper.Orm.UnitOfWork.Mappings;

namespace CompactMapper.Orm.UnitOfWork.Commands.Criteria
{
    internal sealed class EnumEqualsCriterion<T> : Criterion<T>
    {
        private const string Equal = " = ";

        public EnumEqualsCriterion(Queries.Criterion<T> criterion, TablesTree tablesTreeRoot)
            : base(criterion, tablesTreeRoot)
        {
        }


        protected override string ToSql()
        {
            var criterionTextBuilder = new StringBuilder();
            criterionTextBuilder.Append(PropertyName);
            criterionTextBuilder.Append(Equal);
            criterionTextBuilder.Append("'").Append(TargetValue).Append("'");
            return criterionTextBuilder.ToString();
        }
    }
}